﻿using System;
using System.Data;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U;
using webapp4U.BOL;

namespace webapp4U.UI
{
    public partial class ArticleDetail : BasePage
    {
        private int ArticleID = -1;
        private int CateID = -1;

        protected void Page_Load(object sender, EventArgs e)
        {
            //System.Threading.Thread.Sleep(1500);

            ArticleID = Convert.ToInt32(Request.QueryString["ArticleID"]);
            if (ArticleID <= 0)
                Response.Redirect("Default.aspx");

            CateID = webapp4U.BOL.Article.GetArticleCateIDByArticleID(ArticleID);
            // hien thi title

            Title171.Text = webapp4U.BOL.ArticleCategory.GetCateNameByCateID(CateID);

            
            if (webapp4U.BOL.Article.GetImageURLByArticleID(ArticleID) == "")
                TableImage.Visible = false;


            webapp4U.BOL.Article obj = webapp4U.BOL.Article.GetArticleByArticleID(ArticleID);
            lblPostDate.Text = "(" + obj.PostDate + ")";
            lblTitle.Text = obj.Title;
            lblExcerpt.Text = obj.Excerpt;
            lblBody.Text = obj.Body;
            ImageArticle.ImageUrl = ApplicationPath + "UserUpload/Articles/" + obj.ImageURL;

            webapp4U.BOL.Article.UpdateTotalViews(ArticleID);

            this.Load_ThongBaoKhac();
        }

        protected void Load_ThongBaoKhac()
        {
            //load thong bao khac
            List<webapp4U.BOL.Article> obj2 = webapp4U.BOL.Article.GetArticleOtherArticleID(ArticleID, CateID);
            rptArticleOther.DataSource = obj2;
            rptArticleOther.DataBind();
        }
      
    }
}